﻿using RestSharp;
using System;
using Ymatou.ServiceCenter;
using Ymatou.User.Dto;
using Ymatou.User.Dto.PasswordAction;
using YmtAuth.AppService;
using YmtAuth.Dto;
using YmtSystem.CrossCutting;
using ResetService = ServiceStack.Service;

namespace YmtAuth.Web.Handlerv2
{
    
    public class ChangPasswordHandler : ResetService
    {
        private IPasswordAppService AuthAppService { get { return LocalServiceLocator.GetService<IPasswordAppService>(); } }

        [ServiceRegister("/json/reply/PasswordRequestDto", Method.POST)]
        public object Post(PasswordRequestDto request)
        {
            try
            {
                return AuthAppService.ChangUserPasswordById(request);
            }
            catch (Exception ex)
            {
                return ResponseData<ResetPasswordReponseCode>.CreateFail(ResetPasswordReponseCode.DtoError, lastErrorMessage: ex.ToString());
            }
        }
    }
}